{extend name="public/home"/}
{block name='css'}
    <link rel="stylesheet" href="/static/css/ggmm.css">
    <link rel="stylesheet" href="/static/css/gaishu.css">
    
{/block}
{block name="content"}

   <h1>修改密码</h1>
        <div class="bd">
            <form action="">
                <div>
                    <label>新密码：</label>
                    <input type="password" class='newPs' name='userpass'>
                </div>
                <div>
                    <label>重复新密码：</label>
                    <input type="password" class='newPs2'>
                    <span class='red error'></span>
                </div>
                <input type="button" value="提交">
            </form>
        </div>

{/block}
{block name='script'}
<script>
    $(function(){
        $('input[type="button"]').on('click', function(){
          var data = $('form').serialize();
          $.ajax({
            url:'{:url("changepass")}',
            data:data,
            type:'post',
            dataType:'json',
            beforeSend:function(){
              if($('.newPs').val() != $('.newPs2').val() ) {
                $('.error').html('新密码不一致');
                return false;
              }
            },
            success:function(info){
              console.log(info)
              if(info.code == 0) {
                alert('修改成功');
                window.location.reload();
              };
              if(info.code == 1) {
                alert(info.msg);
                window.location.reload();
              }
            }
          })
        })
  })
</script>
{/block}
